home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / prog / ibrary10.zip / IBRARY.DOC < prev    next >
Text File  |  1993-04-23  |  26KB  |  735 lines

  1.                     IBRARY: An ASIC Library
  2.                   =-------------------------=
  3.                           Version 1.0
  4.  
  5.        IBRARY  Copyright (c) 1993  Thomas G. Hanlin III
  6.  
  7.  
  8.  
  9. This is IBRARY, a library of over 135 routines written in
  10. assembly language for use with David A. Visti's ASIC compiler.
  11. You will need ASIC 4.0 or later and a linker to use IBRARY.  An
  12. assembler is not necessary.  The IBRARY collection is
  13. copyrighted and may be distributed only under the following
  14. conditions:
  15.  
  16.    All IBRARY files must be distributed together as a unit.
  17.    No files may be altered, added, or deleted from this unit.
  18.  
  19. YOU USE THIS LIBRARY AT YOUR OWN RISK.  I have tested it on my
  20. own computer, but I will not assume any responsibility for any
  21. problems which IBRARY may cause you.  If you do run into a
  22. problem, please let me know about it, and I will do my best to
  23. verify and repair it.
  24.  
  25. It is expected that if you find IBRARY useful, you will
  26. register your copy.  You may not use IBRARY routines in
  27. programs intended for sale unless you have registered.
  28.  
  29. Registration gets you the latest version of IBRARY, complete
  30. with full source code.  The assembly language code is designed
  31. for MASM 6.0 and may require alteration for other assemblers.
  32. See the ORDER.FRM file for ordering information.
  33.  
  34. Warning: Unregistered use of IBRARY for more than 30 days may
  35. cause the author to practice yodeling outside your bedroom
  36. window at night.  Don't let this happen to you!
  37.  
  38.                        Table of Contents                 page 2
  39.  
  40.  
  41.  
  42.  Synopsis and Legal Info .................................... 1
  43.  
  44.  Table of Contents .......................................... 2
  45.  
  46.  Overview ................................................... 3
  47.  
  48.  Equipment Info ............................................. 4
  49.  
  50.  Extended Math .............................................. 8
  51.  
  52.  Graphics ................................................... 9
  53.  
  54.  Interrupts ................................................ 12
  55.  
  56.  Joystick Support .......................................... 13
  57.  
  58.  Mouse Support ............................................. 14
  59.  
  60.  Miscellaneous ............................................. 17
  61.  
  62.                            Overview                      page 3
  63.  
  64.  
  65.  
  66. As of version 4.0, ASIC became a much more powerful language,
  67. with the introduction of library support.  A library is very
  68. like an extension to a compiler.  It provides capabilities
  69. which are perhaps insufficiently general-purpose to add into
  70. the language itself, but which may nonetheless be of use to
  71. many people.  Libraries let you customize a language to suit
  72. your particular needs.
  73.  
  74. The routines in IBRARY are contained in a library file, which
  75. is denoted by the extension .LIB.  So, the IBRARY library is
  76. named IBRARY.LIB.  How you access this library depends on which
  77. version of the compiler you use: ASIC.EXE or ASICC.EXE.
  78.  
  79. In the case of ASICC.EXE, the command to compile a program
  80. which uses IBRARY looks something like this:
  81.  
  82.    ASICC progname B/OBJ LIB=IBRARY LNK=C:\DOS
  83.  
  84. Here, "progname" is the name of the program to compile.  When
  85. you use a library, compilation turns into a multi-part process.
  86. ASIC first turns your .ASI code into an .OBJ file.  It then
  87. calls your LINK.EXE program to combine the .OBJ file with the
  88. routines you need from IBRARY.LIB, turning the result into an
  89. .EXE program.  In the above command line, the LNK=C:\DOS part
  90. tells ASIC that it can find LINK.EXE in a directory called
  91. C:\DOS.  You will need to use the appropriate directory for
  92. your computer.  Note that LINK.EXE does not come with ASIC.  It
  93. is provided with Microsoft languages and many DOS versions,
  94. though.  Borland also has a linker, called TLINK.EXE.
  95.  
  96. IBRARY includes a batch file, ASICMAKE.BAT, to make all this
  97. easier.  You will need to modify it to have the appropriate
  98. LNK= setting, but once that's done, you can simply type:
  99.  
  100.    ASICMAKE progname
  101.  
  102. ...in order to compile and link your program.
  103.  
  104. In the case of the editor/environment, the initial setup is a
  105. bit different.  From the Compiler menu, pick Advanced Options.
  106. From the Advanced Options menu, do the following:
  107.  
  108.    choose .OBJ output file generation
  109.    set library name to IBRARY
  110.    set link path to wherever your LINK.EXE is (e.g., C:\DOS)
  111.  
  112. It's as easy as that!  You are now set up to use libraries.  A
  113. good first test would be to compile the IBRARY quick demo,
  114. subtly entitled DEMO.ASI.  Give it a try!
  115.  
  116.                         Equipment Info                   page 4
  117.  
  118.  
  119.  
  120. The equipment routines give you information about the computing
  121. environment. This includes both installed software and hardware.
  122.  
  123. The first function allows you to determine if an "enhanced"
  124. keyboard (101-key) is installed.  It may not be able to figure
  125. out what the keyboard is on some older not-quite-clone PCs, in
  126. which case it will take the safe way out and report that there
  127. is no enhanced keyboard.  This routine returns -1 if there is
  128. an enhanced keyboard present, 0 if not.
  129.  
  130.    CALL SUB "KbdType" Enhanced
  131.  
  132. Want to know the type of processor (CPU) being used?  Can do!
  133.  
  134.    CALL SUB "Processor" CPUType
  135.  
  136. The results will be returned as a number which can be decoded
  137. as follows:
  138.  
  139.    0    NEC V20
  140.    1    8088 or 8086
  141.    2    80186
  142.    3    80286
  143.    4    80386
  144.    5    80486
  145.  
  146. Maybe you'd like to check for a CD-ROM drive:
  147.  
  148.    CALL SUB "CDROM" Drives
  149.  
  150. This tells you how many logical drives exist, if there is a
  151. CD-ROM available. If not, it will return 0.  Note that the
  152. CD-ROM installation check conflicts with the GRAPHICS.COM
  153. installation check for DOS 4.0, due to some screw-up at IBM or
  154. Microsoft.
  155.  
  156. The number of floppy drives installed is retrieved like this:
  157.  
  158.    CALL SUB "Floppies" Drives
  159.  
  160.                         Equipment Info                   page 5
  161.  
  162.  
  163.  
  164. There may be up to four floppy drives in a system; however, the
  165. AT CMOS data area only directly supports two. This makes it
  166. easy to find out what kind of drives the first two are, but not
  167. the second two.  Oh well, guess we'll have to settle for what
  168. we can get, right?
  169.  
  170.    CALL SUB "FloppyType" Drive1 Drive2
  171.  
  172. The results from FloppyType are returned as follows:
  173.  
  174.    0    no drive
  175.    1    5 1/4"    360K
  176.    2    5 1/4"    1.2M
  177.    3    3 1/2"    720K
  178.    4    3 1/2"    1.44M
  179.  
  180. Result codes of 5-7 are available, but not yet defined.  One
  181. might guess that the 2.88M drive supported by DOS 5.0 will be
  182. drive type 5.  Has anybody seen one of those puppies yet?
  183.  
  184. New memory types sure have burgeoned over the years...
  185. expanded, extended, and now XMS.  There are routines to check
  186. all of these:
  187.  
  188.    REM get total extended memory installed
  189.    CALL SUB "AllExtMem" AllExt&
  190.  
  191.    REM get BIOS extended memory installed
  192.    CALL SUB "GetExtM" BiosExt&
  193.  
  194.    REM get expanded (EMS) memory installed
  195.    CALL SUB "GetEMSm" TotalPages FreePages
  196.  
  197.    REM get XMS memory installed
  198.    CALL SUB "GetXMSm" BigFree& TotalFree&
  199.  
  200. When you're dealing with extended memory, whether it be
  201. BIOS-type or using the XMS standard, the results are returned
  202. in kilobytes.  Multiply 'em by 1024 to convert to bytes.  When
  203. you're dealing with expanded memory (EMS), the results are in
  204. pages of 16,384 bytes.
  205.  
  206. I might note, by the way, that Microsoft seems to have
  207. intentionally crippled the XMS standard.  It can only support a
  208. maximum of 64 megabytes.  This may seem like a lot now, but
  209. it'll seem cramped soon enough.
  210.  
  211. A few more routines to get the versions of EMS and XMS, if any:
  212.  
  213.    CALL SUB "GetEMSv" MajorV MinorV
  214.    CALL SUB "GetXMSv" MajorV MinorV
  215.  
  216. These return the major and minor version numbers as two
  217. separate integers. For example, EMS 4.0 would return major
  218. version 4, minor version 0.
  219.  
  220.                         Equipment Info                   page 6
  221.  
  222.  
  223.  
  224. It's nice to know a little about the operating environment.
  225. With the below routines, you can find out what the DOS version
  226. is; what version of 4DOS, if any, is in use; and whether
  227. Microsoft Windows is running.
  228.  
  229.    CALL SUB "GetDOSv" MajorV MinorV
  230.    CALL SUB "Get4DOSv" MajorV MinorV
  231.    CALL SUB "WinCheck" MajorV MinorV
  232.  
  233. These return results as major and minor version numbers, as
  234. discussed on the previous page.  The Get4DOSv and WinCheck
  235. routines return zeroes if 4DOS and Windows, respectively, are
  236. not available.
  237.  
  238. There are a couple of curious features of GetDOSv to keep in
  239. mind.  If the version is 10 or higher, you're running in OS/2
  240. compatibility mode.  DOS version 10 is actually OS/2 1.0,
  241. version 20 is OS/2 2.0, and so on. Secondly, if you're using
  242. DOS 5.0, the version reported may not be 5.0-- DOS 5.0 can be
  243. told to reply with a lower version number to allow some older
  244. software (which checks for a specific DOS version) to run
  245. properly.
  246.  
  247. One final routine that should be of some value is the one that
  248. allows you to find out what kind of display is available.  It
  249. tells you the specific adapter and whether the display is color
  250. or monochrome.  There is one case in which it can be confused,
  251. however-- if the adapter is CGA, the display is assumed to be
  252. color, since there is no way for the computer to know any
  253. differently.  So, although this routine provides a good idea of
  254. what is available, it would be a good idea to provide an option
  255. to tell the program that a monochrome display is attached.
  256. Microsoft normally uses "/B" for this purpose, so that might be
  257. a good standard to stick with.
  258.  
  259.    CALL SUB "GetDisplay" Adapter Mono
  260.  
  261. This returns Mono = -1 for a monochrome display, or Mono = 0
  262. for a color display.  The Adapter may be any of the following:
  263.  
  264.    1    MDA
  265.    2    Hercules
  266.    3    CGA
  267.    4    EGA
  268.    5    MCGA
  269.    6    VGA
  270.  
  271.                         Equipment Info                   page 7
  272.  
  273.  
  274.  
  275. Aside from some of the oldest semi-clones, it's possible to
  276. find out what sort of machine you're using by looking at a
  277. specific data byte.  You can access this as follows:
  278.  
  279.    CALL SUB "PCType" PcType
  280.  
  281. The result will need decoding.  Here are some known values:
  282.  
  283.    255   PC or XT
  284.    254   XT
  285.    253   PCjr
  286.    252   PC AT
  287.    251   XT
  288.    250   PS/2 Model 30
  289.    249   PC Convertible
  290.    248   PS/2 Model 70 or 80
  291.    154   Compaq Portable
  292.     45   Compaq Portable
  293.  
  294. Likewise, all but some of the oldest semi-clones maintain a
  295. BIOS date value which tells you how old the BIOS ROM is.  This
  296. can be retrieved with the following routine:
  297.  
  298.    CALL SUB "PCDate" PCDate$
  299.  
  300. If your program is running on one of the rare old machines
  301. which don't maintain a valid BIOS date, this routine will
  302. return "No Date " instead of an actual date.
  303.  
  304. As far as a program is concerned, DR DOS is essentially the
  305. same as MS-DOS.  Still, it's always nice to know what sort of
  306. operating environment you have.  You can find out whether your
  307. program is running under DR DOS with the following function:
  308.  
  309.    CALL SUB "DrDos" DrDos
  310.    IF DRDOS = 0 THEN
  311.       PRINT "MS-DOS"
  312.    ELSE
  313.       PRINT "DR DOS"
  314.    ENDIF
  315.  
  316. The number of serial and parallel ports available can be
  317. readily obtained:
  318.  
  319.    CALL SUB "CommPorts" CommPorts
  320.  
  321.    CALL SUB "PrtPorts" PrtPorts
  322.  
  323.                          Extended Math                   page 8
  324.  
  325.  
  326.  
  327. The extended math routines provide a number of simple binary
  328. functions which operate on an integer as a stream of bits.  You
  329. may shift or rotate the bits in an integer by an arbitrary
  330. amount in either direction.
  331.  
  332. Note that the normal ASIC integer has a length of 16 bits.
  333.  
  334.    CALL SUB "LShift" Number ShiftCount
  335.  
  336.    CALL SUB "RShift" Number ShiftCount
  337.  
  338.    CALL SUB "LRotate" Number ShiftCount
  339.  
  340.    CALL SUB "RRotate" Number ShiftCount
  341.  
  342. An identical set of routines is provided for long integers,
  343. which have a length of 32 bits.
  344.  
  345.    CALL SUB "LShiftL" Number& ShiftCount
  346.  
  347.    CALL SUB "RShiftL" Number& ShiftCount
  348.  
  349.    CALL SUB "LRotateL" Number& ShiftCount
  350.  
  351.    CALL SUB "RRotateL" Number& ShiftCount
  352.  
  353.                        Graphics Support                  page 9
  354.  
  355.  
  356.  
  357. Much of the design of ASIC appears to be oriented on the notion
  358. of creating the smallest possible programs.  In that respect,
  359. it is perhaps not surprising that ASIC doesn't include strong
  360. graphics support.  IBRARY provides support for EGA and VGA
  361. modes which ASIC doesn't.  A future version of IBRARY will
  362. include advanced support for many more video modes.
  363.  
  364.   Mode   Description
  365.   ====   ================================================
  366.     8    640x200,  16 colors, 80x25 text, EGA or better
  367.    11    640x480,   2 colors, 80x25 text, VGA or better
  368.    12    640x480,  16 colors, 80x25 text, VGA or better
  369.    13    320x200, 256 colors, 40x25 text, VGA or better
  370.    N0    360x480, 256 colors, 45x60 text, VGA or better
  371.    N1    320x400, 256 colors, 40x25 text, VGA or better
  372.  
  373. The graphics routines all use the same nomenclature: a G,
  374. followed by a mode number, followed by the specific name.  This
  375. generic naming convention is used so that this chapter can
  376. refer to all available modes.  For example, if I say "G#Color"
  377. and you're using mode 12, you'd actually use "G12Color" in your
  378. program.  Ok?
  379.  
  380. You just use G#Mode with a non-zero value to enter graphics
  381. mode, or zero to restore text mode.  The text mode is assumed
  382. to be the normal 80x25 color mode.  If this would not be your
  383. choice, you can safely use the ASIC SCREEN statement to pick a
  384. mode that's more to your liking.
  385.  
  386. Here's an example for typical handling of one of the non-SVGA
  387. modes (in this case, mode 12):
  388.  
  389.    CALL SUB "G12Mode" 1
  390.    REM *** your main program goes here ***
  391.    CALL SUB "G12Mode" 0
  392.  
  393.                        Graphics Support                 page 10
  394.  
  395.  
  396.  
  397. One difference between ASIC and IBRARY is that, instead of
  398. each "draw" command requiring a color parameter as in ASIC,
  399. IBRARY provides a separate color command:
  400.  
  401.    CALL SUB "G#Color" Foreground Background
  402.  
  403. The foreground color is used by all graphics routines.  The
  404. background color is used by the G#Cls routine.  Both foreground
  405. and background colors are used in by G#Write and G#WriteLn.
  406.  
  407. Here is a list of the corresponding routines, first ASIC, then
  408. IBRARY (replace the "#" with the appropriate mode number):
  409.  
  410.    REM get the color of a specified point
  411.    colour = POINT(x, y)
  412.    CALL SUB "G#GetPel" x y colour
  413.  
  414.    REM set the color of a specified point
  415.    PSET (x, y), colour
  416.    CALL SUB "G#Color" colour, backgnd
  417.    CALL SUB "G#Plot" x y
  418.  
  419.    REM clear the screen and home the cursor (if any)
  420.    CLS
  421.    CALL SUB "G#Cls"
  422.  
  423.    REM get the current cursor position
  424.    Row = CSRLIN
  425.    Column = POS(0)
  426.    CALL SUB "G#GetLocate" Row Column
  427.  
  428.    REM set the current cursor position
  429.    LOCATE Row, Column
  430.    CALL SUB "G#Locate" Row Column
  431.  
  432.    REM display a string without a carriage return and linefeed
  433.    PRINT St$;
  434.    CALL SUB "G#Write" St$
  435.  
  436.    REM display a string with a carriage return and linefeed
  437.    PRINT St$
  438.    CALL SUB "G#WriteLn" St$
  439.  
  440. If you need to print a number rather than a string, just use
  441. the BASIC function STR$ to convert it.  If you don't want a
  442. leading space, you can use the IBRARY routine, StrNB:
  443.  
  444.    CALL SUB "StrNB" Number St$
  445.  
  446.                        Graphics Support                 page 11
  447.  
  448.  
  449.  
  450. The IBRARY library has other graphics routines which have no
  451. ASIC equivalent.  Here's a list:
  452.  
  453.    REM get the current colors
  454.    CALL SUB "G#GetColor" Foreground Background
  455.  
  456.    REM draw a line
  457.    CALL SUB "G#Line" x1 y1 x2 y2
  458.  
  459.    REM draw a box (set filled = 0 for frame, = 1 to fill it)
  460.    CALL SUB "G#Box" x1 y1 x2 y2 filled
  461.  
  462.    REM get a VGA palette value
  463.    CALL SUB "GetPalRGB" Colour RedI GreenI BlueI
  464.  
  465.    REM set a VGA palette value
  466.    CALL SUB "SetPalRGB" Colour RedI GreenI BlueI
  467.  
  468.  
  469. The most obvious aspect of palettes is in the ability to select
  470. a set of colors suited to a specific application.  When showing
  471. a picture of the sea, you might want mostly blues and greens,
  472. for instance.  There are other implications in the ability to
  473. quickly change a color across the entire screen, however.  It
  474. allows for simple animation, the ability to fade in or fade
  475. out, and other interesting effects.  Let your imagination run
  476. loose and experiment a little!  You'll be surprised by the
  477. power of palette manipulation.
  478.  
  479.                            Interrupts                   page 12
  480.  
  481.  
  482.  
  483. The interrupt routines give you access to some of the more
  484. common BIOS and DOS interrupts, with a couple of convenience
  485. features thrown in for good measure.
  486.  
  487. NOTE that these routines access the computer at a very low
  488. level.  If you don't know what you're doing or make a mistake,
  489. you could cause serious trouble.  Be warned!
  490.  
  491. Three routines are provided for accessing common interrupts.
  492. They allow you to set the AX, BX, CX, and DX registers, and
  493. return the new values of the same, plus the flags.
  494.  
  495.    REM  access to INT 21h, the DOS function handler
  496.    CALL SUB "DosInt" AX BX CX DX Flags
  497.  
  498.    REM  access to INT 10h, the BIOS video handler
  499.    CALL SUB "VidInt" AX BX CX DX Flags
  500.  
  501.    REM  access to INT 16h, the BIOS keyboard handler
  502.    CALL SUB "KbdInt" AX BX CX DX Flags
  503.  
  504. Each of the 16-bit registers AX, BX, CX and DX can be divided
  505. in half and accessed as 8-bit values: AH, AL, BH, BL, and so
  506. on.  To make it easier to work with the registers as either
  507. 8-bit or 16-bit quantities, IBRARY includes routines to split a
  508. 16-bit word into two 8-bit bytes, and vice versa:
  509.  
  510.    CALL SUB "SplitWord" Word HiByte LoByte
  511.  
  512.    CALL SUB "JoinBytes" HiByte LoByte Word
  513.  
  514. The Flags value is a set of bit flags indicating the value of
  515. the processor's flag register.  Bit 0 contains the carry flag
  516. and bit 6 contains the zero flag.  There are a few other flags
  517. involved, but you should never need to access them.
  518.  
  519.                        Joystick Support                 page 13
  520.  
  521.  
  522.  
  523. The joystick routines allow you to read the positions and
  524. buttons of up to two joysticks.  If only one joystick is
  525. attached, the results for the second joystick will usually be
  526. meaningless.  In the case of the FlightStick joystick, if only
  527. one joystick is attached, the value for the Y position of the
  528. second joystick will indicate the FlightStick throttle setting.
  529.  
  530. The joysticks are labeled "A" and "B" for these routines, where
  531. "A" is the first joystick.
  532.  
  533. You can read the joystick buttons individually or all at once.
  534. If speed is an issue, you should read the buttons all at once,
  535. as this is considerably faster than reading them one at a time
  536. (assuming you wish to read more than one button).
  537.  
  538.    CALL SUB "JButtonA1" Pressed
  539.    CALL SUB "JButtonA2" Pressed
  540.    CALL SUB "JButtonB1" Pressed
  541.    CALL SUB "JButtonB2" Pressed
  542.  
  543.    CALL SUB "JButtons" A1Pressed A2Pressed B1Pressed B2Pressed
  544.  
  545. The value returned will be -1 if the button is pressed or 0 if
  546. it is not pressed.
  547.  
  548. You can also get the position of the joysticks.  This is
  549. returned as a pair of X,Y coordinates for each joystick.  The
  550. starting and ending positions depend on the individual
  551. joystick, game adapter, and computer, so your program must
  552. calibrate itself to the individual joystick.  I find a range of
  553. about 5-140 on my FlightStick; your mileage may vary.
  554.  
  555.    CALL SUB "JPos" AX AY BX BY
  556.  
  557. Note that the joystick routines are BIOS-dependent.  They will
  558. not work on some of the oldest PCs (those made before 1983 or
  559. thereabouts).
  560.  
  561.                          Mouse Support                  page 14
  562.  
  563.  
  564.  
  565. The mouse routines provide full-featured mouse support.  You
  566. can see if a mouse is available and how many buttons it has,
  567. get the cursor position (either the current position or the
  568. position at the last press or release of a specified button),
  569. set the cursor position, change the cursor, set the mouse
  570. range, get hardware information about the mouse, and so on.
  571.  
  572. There are two unusual mouse modes to be aware of.  One is text
  573. mode, which is mapped to a 640x200 virtual display.  So, to
  574. convert the results to text format, you need to divide the
  575. cursor position by eight and add one.  To convert from text
  576. format, subtract one and multiply by eight.
  577.  
  578. The second unusual mode is 320x200 CGA mode, which is also
  579. mapped to 640x200. To convert the coordinates to this mode,
  580. divide X by two.  To convert from this mode, multiply the X
  581. coordinate by two.
  582.  
  583. All other modes use the actual display coordinates instead of a
  584. bizarro virtual screen.  Why the peculiar CGA and text modes?
  585. Well, evidently Microsoft never thought there'd be any video
  586. adapters besides MDA and CGA, and decided to create a single
  587. virtual screen size that worked for all modes. Not a bad idea,
  588. I guess, but rather shortsighted.  Oh well.
  589.  
  590. One other nuisance that you may run into is that the mouse
  591. cursor can't be directly turned on or off.  A "cursor
  592. visibility" count is maintained-- if the mouse cursor was
  593. turned on twice, you'll need to turn it off twice before it
  594. will actually disappear.
  595.  
  596. Before using the mouse, you must initialize it.  The
  597. initialization routine also checks to make sure that a mouse is
  598. installed and tells you how many buttons it has.  It's best to
  599. initialize the mouse after setting the screen mode, so the
  600. mouse driver understands what mode you're using.  Not all mouse
  601. drivers support all screen modes, but you can reasonably expect
  602. any current mouse driver to support MDA, CGA, EGA, and VGA.
  603. Hercules graphics mode is rarely supported, as it must be set
  604. through direct hardware access rather than the standard
  605. techniques, so the mouse driver has little way of knowing that
  606. you've changed the mode.
  607.  
  608. The mouse routines will work equally well with two-button or
  609. three-button rodents.  The middle button functions will return
  610. 0 with two-button mice.
  611.  
  612.                          Mouse Support                  page 15
  613.  
  614.  
  615.  
  616. I won't go into great detail on these routines, because they're
  617. pretty much self-explanatory.  The mouse is a fairly easy
  618. device to deal with, despite the quirks of Microsoft's driver.
  619.  
  620. You can initialize the mouse driver like so:
  621.  
  622.    CALL SUB "MInit" Buttons
  623.  
  624. This returns the number of mouse buttons available.  If there
  625. is no mouse, zero will be returned.  Initialize the mouse AFTER
  626. setting the screen mode, so it knows what the screen is like.
  627.  
  628. You can make the mouse cursor visible or invisible.  It will
  629. function just as well in either state.  See the previous page
  630. for some quirks.
  631.  
  632.    CALL SUB "MShow"
  633.    CALL SUB "MHide"
  634.  
  635. There are many ways to get the mouse cursor position.  You can
  636. get the current position, the position at which the mouse was
  637. located when a particular button was pressed, or the position
  638. when a button was released. If you choose a past position, you
  639. can also find out how many presses or releases of the button
  640. have taken place since you last checked.
  641.  
  642.    REM current coordinates
  643.    CALL SUB "MWhereX" X
  644.    CALL SUB "MWhereY" Y
  645.  
  646.    REM number of presses of a given button
  647.    REM and mouse position at last press
  648.    CALL SUB "MLClick" Count X Y
  649.    CALL SUB "MMClick" Count X Y
  650.    CALL SUB "MRClick" Count X Y
  651.  
  652.    REM number of releases of a given button
  653.    REM and mouse position at last release
  654.    CALL SUB "MLRelease" Count X Y
  655.    CALL SUB "MMRelease" Count X Y
  656.    CALL SUB "MRRelease" Count X Y
  657.  
  658.                          Mouse Support                  page 16
  659.  
  660.  
  661.  
  662. If you'd prefer to find out which buttons are currently
  663. pressed, no problem:
  664.  
  665.    CALL SUB "MLButton" IsDown
  666.    CALL SUB "MMButton" IsDown
  667.    CALL SUB "MRButton" IsDown
  668.  
  669. Of course, you can also set the cursor location:
  670.  
  671.    CALL SUB "MLocate" X Y
  672.  
  673. The mouse cursor range can be restricted to a given area of the
  674. screen.  This area is expressed by giving the upper left corner
  675. and lower right corner of the rectangular area to which to
  676. restrict the cursor.
  677.  
  678.    CALL SUB "MWindow" X1 Y1 X2 Y2
  679.  
  680. There are a variety of cursor shapes available for graphics
  681. mode:
  682.  
  683.     0    hourglass ("please wait, program is working" symbol)
  684.     1    pointing arrow (default)
  685.     2    pointing hand
  686.     3    crosshair
  687.     4    target (box in a box)
  688.     5    grabbing hand
  689.  
  690. If you have ideas for more, let me know and I'll see what I can
  691. do.  Cursor shapes are not unduly difficult to define, although
  692. it's technical enough so that I decided to avoid confusion by
  693. leaving direct handling out of IBRARY.
  694.  
  695.    CALL SUB "MCursorG" CursorNr
  696.  
  697.                          Miscellaneous                  page 17
  698.  
  699.  
  700.  
  701. If there are not (yet) enough routines in a category to give
  702. them their own classification, they come to roost here, in good
  703. ol' Miscellaneous.  At the moment, this consists of a string
  704. routine and some DOS output routines.
  705.  
  706. The StrNB routine works like ASIC's built-in STR$ function, but
  707. strips all leading blanks from the result.  It works on plain
  708. integers.
  709.  
  710.    CALL SUB "StrNB" Number Result$
  711.  
  712. The DOS output routines allow you to send output to the default
  713. DOS device-- normally the screen, although it can be redirected
  714. by the user to another device or to a file.  We start with a
  715. generic PRINT replacement:
  716.  
  717.    CALL SUB "DosPrint" St$
  718.  
  719. That sends a string to standard output.  If you want a carriage
  720. return and linefeed, you must add them yourself:
  721.  
  722.    CrLf$ = CHR$(13) + CHR$(10)
  723.    St$ = St$ + CrLf$
  724.  
  725. The rest of the DOS output routines require ANSI.SYS or another
  726. ANSI driver to be loaded.  They send the appropriate ANSI codes
  727. to standard output.
  728.  
  729.    CALL SUB "DosCls"
  730.  
  731.    CALL SUB "DosColor" Foreground Background
  732.  
  733.    CALL SUB "DosLocate" Row Column
  734.  
  735.